<extend name="Public/base"/>

<block name="body">
<div class="main-title">
    <h2>商圈管理</h2>
</div>

<div class="cf">
    <div class="fl">
        <a class="btn" href="{:U('BusinessRange/add')}" style="background: dodgerblue">新 增</a>
        <button class="btn ajax-post" style="background: orange" url="{:U('BusinessRange/ready',array('method'=>'resumeUser'))}" target-form="ids">未开始</button>
        <button class="btn ajax-post" url="{:U('BusinessRange/start',array('method'=>'resumeUser'))}" target-form="ids">开 始</button>
        <button class="btn ajax-post" url="{:U('BusinessRange/end',array('method'=>'forbidUser'))}" target-form="ids">结 束</button>
        <button class="btn ajax-post " style="background: orangered" url="{:U('BusinessRange/clear',array('method'=>'deleteUser'))}" target-form="ids">删 除</button>
    </div>

    <!-- 高级搜索 -->
    <div class="search-form fr cf">
        <div class="sleft">
            <input type="text" name="keyword" class="search-input" value="{:I('keyword')}" placeholder="请输入企业名称或管理员名称">
            <a class="sch-btn" href="javascript:;" id="search" url="{:U('BusinessRange/index')}"><i class="btn-search"></i></a>
        </div>
    </div>
</div>

    <div class="data-table table-striped">
        <table>
            <thead>
            <tr>
                <th class="row-selected">
                    <input class="checkbox check-all" type="checkbox">
                </th>
                <th>ID</th>
                <th>商圈图片</th>
                <th>商圈名称</th>
                <th>订单类型及限额</th>
                <th>进行时间</th>
                <th>支付方式</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <notempty name="list">
                <volist name="list" id="item">
                    <tr>
                        <td><input class="ids row-selected" type="checkbox" name="ids[]" id="" value="{$item['id']}"> </td>
                        <td>{$item.id}</td>
                        <td><img height="40" src="{$item.image_src}" alt=""></td>
                        <td><a href="__URL__/edit/id/{$item.id}">{$item.area_name}</a></td>
                        <td>
                         <if condition = "$item.order1 gt 0" >
                             企业点餐，限额 ：{$item.order1}
                         </if>

                            <if condition = "$item.order2 gt 0" >
                                |   拼团，限额 ：{$item.order2}
                            </if>

                            <if condition = "$item.order3 gt 0" >
                                |  商超，限额 ：{$item.order3}
                            </if>
                        </td>
                        <td> {$item.work_time} 分钟</td>
                        <td>
                            <?php
                            foreach($item['pay_skills'] as $k => $v){
                                if($k != 0){
                                   echo ",".$v['payment_name'];
                                }else{
                                   echo $v['payment_name'];
                                }
                        }
                        ?>
                        </td>
                        <td> <if condition="$item.status eq 1">
                            &nbsp;未开始
                            <elseif condition="$item.status eq 2" />
                            <a href="">拼团进行中</a>
                            <else/>
                            结束
                        </if>
                        </td>
                        <td>
                            <a title="编辑" href="__URL__/edit/id/{$item.id}">编辑</a>
                            <a class="confirm ajax-get" title="删除" href="__URL__/delete/id/{$item.id}">删除</a>
                        </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>

<div>
    {$page}
</div>

</block>
<block name="script">

    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript">
        $(function() {
            //导航高亮
            highlight_subnav("{:U('BusinessRange/index')}");
            //点击排序
            $('.list_sort').click(function(){
                var url = $(this).attr('url');
                var ids = $('.ids:checked');
                var param = '';
                if(ids.length > 0){
                    var str = new Array();
                    ids.each(function(){
                        str.push($(this).val());
                    });
                    param = str.join(',');
                }

                if(url != undefined && url != ''){
                    window.location.href = url + '/ids/' + param;
                }
            });



            //搜索功能
            $("#search").click(function(){
                var url = $(this).attr('url');
                var query  = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
                query = query.replace(/^&/g,'');
                if( url.indexOf('?')>0 ){
                    url += '&' + query;
                }else{
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e){
                if(e.keyCode === 13){
                    $("#search").click();
                    return false;
                }
            });

        });

    </script>
</block>
